package com.ztesoft.book.admin.controller.quartz;

import com.ztesoft.book.common.utils.Result;
import com.ztesoft.book.common.utils.query.PageBO;
import com.ztesoft.book.core.quartz.schedulejoblog.dto.ScheduleJobLogDTO;
import com.ztesoft.book.core.quartz.schedulejoblog.service.ScheduleJobLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Description: 定时任务日志
 * @Author: YangFan
 * @Date: 2021-03-22 14:32
 */
@RestController
@RequestMapping("/quartz/scheduleLog")
public class ScheduleJobLogController {

    @Autowired
    private ScheduleJobLogService scheduleJobLogService;


    /**
     * 方法功能描述:
     * < 定时任务日志列表 >
     *
     * @param params 【参数 1 注释说明】
     * @return Result                        【返回值 注释说明】
     * @author YangFan
     * @date 2021-06-22 17:05
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params) {
        PageBO page = scheduleJobLogService.queryPage(params);

        return Result.success().put("page", page);
    }

    /**
     * 方法功能描述:
     * < 定时任务日志信息 >
     *
     * @param logId 【参数 1 注释说明】
     * @return Result                        【返回值 注释说明】
     * @author YangFan
     * @date 2021-06-22 17:05
     */
    @RequestMapping("/info/{logId}")
    public Result info(@PathVariable("logId") Long logId) {
        ScheduleJobLogDTO scheduleJobLogDto = scheduleJobLogService.getById(logId);
        return Result.success().put("log", scheduleJobLogDto);
    }
}
